#ifndef _CAN_CAN_H
#define _CAN_CAN_H

#include <stdint.h>
#include <stdbool.h>
#include "gd32a508.h"

#define TX_MES1_ID   0x0900BCF1
#define RX_MES1_ID   0x0900F1BC
#define TX_MES2_ID   0x0901BCF1
#define RX_MES2_ID   0x0901F1BC
#define TX_MES3_ID   0x0902BCF1
#define RX_MES3_ID   0x0902F1BC


typedef enum
{
        //sub_can
    EM_CAN_0,
        //chg_can
    EM_CAN_1,
        //main_can
    EM_CAN_2
}CAN_CH_DEF;

typedef struct
{
    FlagStatus sub_receive_flag;
    can_trasnmit_message_struct sub_transmit_message;
    can_receive_message_struct  sub_receive_message;
    FlagStatus sub_receive_mes1_flag;
    can_receive_message_struct  sub_receive_mes1_message;

    FlagStatus chg_receive_flag;
    can_trasnmit_message_struct chg_transmit_message;
    can_receive_message_struct  chg_receive_message;

    FlagStatus main_receive_flag;
    can_trasnmit_message_struct main_transmit_message;
    can_receive_message_struct  main_receive_message;
    
    void (*fdeinit)(void);
    void (*finit)(CAN_CH_DEF,bool);
    void (*fwrite_data)(CAN_CH_DEF,uint32_t,uint8_t*,uint8_t);
    void (*fcommunication_loop)(void);
} dv_CAN_TypeDef;

extern dv_CAN_TypeDef dv_CAN;
extern void init_bsp_can(void);

#endif